{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "515ebe61-2d76-4cd2-b0d5-0ed01b304a0e",
   "metadata": {
    "tags": []
   },
   "source": [
    "## 对鲍鱼各属性进行数值分析"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84691c9d-1ea6-42c4-bca7-6e6689e746ee",
   "metadata": {},
   "source": [
    "### 主要内容：\n",
    "* 读取所有连续类型的数据。\n",
    "* 分别计算属性的均值方差及属性间的相关系数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "26b108fa-9df5-443d-b1ef-31c102c8caf0",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Length            0.523992\n",
      "Diameter          0.407881\n",
      "Height            0.139516\n",
      "Whole weight      0.828742\n",
      "Shucked weight    0.359367\n",
      "Viscera weight    0.180594\n",
      "Shell weight      0.238831\n",
      "Rings             9.933684\n",
      "dtype: float64\n",
      "Length             0.014422\n",
      "Diameter           0.009849\n",
      "Height             0.001750\n",
      "Whole weight       0.240481\n",
      "Shucked weight     0.049268\n",
      "Viscera weight     0.012015\n",
      "Shell weight       0.019377\n",
      "Rings             10.395266\n",
      "dtype: float64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Length</th>\n",
       "      <th>Diameter</th>\n",
       "      <th>Height</th>\n",
       "      <th>Whole weight</th>\n",
       "      <th>Shucked weight</th>\n",
       "      <th>Viscera weight</th>\n",
       "      <th>Shell weight</th>\n",
       "      <th>Rings</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Length</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.986812</td>\n",
       "      <td>0.827554</td>\n",
       "      <td>0.925261</td>\n",
       "      <td>0.897914</td>\n",
       "      <td>0.903018</td>\n",
       "      <td>0.897706</td>\n",
       "      <td>0.556720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Diameter</th>\n",
       "      <td>0.986812</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.833684</td>\n",
       "      <td>0.925452</td>\n",
       "      <td>0.893162</td>\n",
       "      <td>0.899724</td>\n",
       "      <td>0.905330</td>\n",
       "      <td>0.574660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Height</th>\n",
       "      <td>0.827554</td>\n",
       "      <td>0.833684</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.819221</td>\n",
       "      <td>0.774972</td>\n",
       "      <td>0.798319</td>\n",
       "      <td>0.817338</td>\n",
       "      <td>0.557467</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Whole weight</th>\n",
       "      <td>0.925261</td>\n",
       "      <td>0.925452</td>\n",
       "      <td>0.819221</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.969405</td>\n",
       "      <td>0.966375</td>\n",
       "      <td>0.955355</td>\n",
       "      <td>0.540390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Shucked weight</th>\n",
       "      <td>0.897914</td>\n",
       "      <td>0.893162</td>\n",
       "      <td>0.774972</td>\n",
       "      <td>0.969405</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.931961</td>\n",
       "      <td>0.882617</td>\n",
       "      <td>0.420884</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Viscera weight</th>\n",
       "      <td>0.903018</td>\n",
       "      <td>0.899724</td>\n",
       "      <td>0.798319</td>\n",
       "      <td>0.966375</td>\n",
       "      <td>0.931961</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.907656</td>\n",
       "      <td>0.503819</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Shell weight</th>\n",
       "      <td>0.897706</td>\n",
       "      <td>0.905330</td>\n",
       "      <td>0.817338</td>\n",
       "      <td>0.955355</td>\n",
       "      <td>0.882617</td>\n",
       "      <td>0.907656</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.627574</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Rings</th>\n",
       "      <td>0.556720</td>\n",
       "      <td>0.574660</td>\n",
       "      <td>0.557467</td>\n",
       "      <td>0.540390</td>\n",
       "      <td>0.420884</td>\n",
       "      <td>0.503819</td>\n",
       "      <td>0.627574</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  Length  Diameter    Height  Whole weight  Shucked weight  \\\n",
       "Length          1.000000  0.986812  0.827554      0.925261        0.897914   \n",
       "Diameter        0.986812  1.000000  0.833684      0.925452        0.893162   \n",
       "Height          0.827554  0.833684  1.000000      0.819221        0.774972   \n",
       "Whole weight    0.925261  0.925452  0.819221      1.000000        0.969405   \n",
       "Shucked weight  0.897914  0.893162  0.774972      0.969405        1.000000   \n",
       "Viscera weight  0.903018  0.899724  0.798319      0.966375        0.931961   \n",
       "Shell weight    0.897706  0.905330  0.817338      0.955355        0.882617   \n",
       "Rings           0.556720  0.574660  0.557467      0.540390        0.420884   \n",
       "\n",
       "                Viscera weight  Shell weight     Rings  \n",
       "Length                0.903018      0.897706  0.556720  \n",
       "Diameter              0.899724      0.905330  0.574660  \n",
       "Height                0.798319      0.817338  0.557467  \n",
       "Whole weight          0.966375      0.955355  0.540390  \n",
       "Shucked weight        0.931961      0.882617  0.420884  \n",
       "Viscera weight        1.000000      0.907656  0.503819  \n",
       "Shell weight          0.907656      1.000000  0.627574  \n",
       "Rings                 0.503819      0.627574  1.000000  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "data = pd.read_csv('abalone.data', sep=',',usecols=['Length','Diameter','Height','Whole weight','Shucked weight','Viscera weight','Shell weight','Rings'])\n",
    "col_mean=data.mean()\n",
    "print(col_mean)\n",
    "col_v=data.var()\n",
    "print(col_v)\n",
    "data.corr(method='pearson')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
